package com.dayuan.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dayuan.bean.Goods_type;
import com.dayuan.dao.Goods_typeMapper;
import com.dayuan.vo.Goods_typeVo;

//home页面商品列表(递归方式)
@Service
public class Goods_typeService {

	@Resource(name = "goods_typeMapper")
	private Goods_typeMapper gm;

	public List<Goods_type> goods_type(int pid) {
		return gm.selectGoods_type(pid);
	}

	public List<Goods_typeVo> GetGoods_type(int id) {
		List<Goods_typeVo> result = new ArrayList<Goods_typeVo>();

		List<Goods_type> list = goods_type(id);
		
		for (Goods_type goods_type : list) {
			Goods_typeVo goods_typeVo = new Goods_typeVo(goods_type.getId(), goods_type.getType_name(),
					goods_type.getPid(), GetGoods_type(goods_type.getId()),goods_type.getPicture());
			result.add(goods_typeVo);
			
		}
		
		return result;
	}

}
